<template>
  <div>
    <router-view/>
  </div>
</template>

<script>
  import { mapState, mapActions } from 'vuex'

  export default {
    name: 'App',
    computed: {
      ...mapState({
        //
        merchantInfo: state => state.merchants.merchantInfo
      })
    },
    created() {
      this.initMerchantInfo()
    },
    methods: {
      ...mapActions(['GetMerchantInfo', 'ClearMerchantInfo']),
      async initMerchantInfo() {
        const host = document.domain
        const {GetMerchantInfo, ClearMerchantInfo} = this

        if (this.merchantInfo && this.merchantInfo.domainName !== hostName) {
          await ClearMerchantInfo()
        }
        if (this.merchantInfo) {
          return
        }
        await GetMerchantInfo(host)
      }
    }
  }
</script>

<style scoped lang="scss">


</style>
